package br.com.financeiro.controllers;

import java.util.List;

import javax.faces.model.SelectItem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Component;

import br.com.financeiro.dominio.TipoConta;
import br.com.financeiro.services.AbstractService;

@Component
@Scope("session")
public class TipoContaMBean extends AbstractMBean<TipoConta>{
	
	public TipoContaMBean(){
		obj = new TipoConta();
	}

	@Override
	protected String getDir() {
		return "/pages/tipo_conta";
	}
	
	@Autowired
	public void setService(AbstractService<TipoConta> service){
		super.setService(service);
	}
	
	@Override
	@Secured("ROLE_ADMIN")
	public String novo(){
		obj = new TipoConta();
		return super.novo();
	}
	
	public List<SelectItem> getTiposConta() throws Exception{
		return toSelectItens(getLista(), "id", "descricao");
	}

}
